mimic_sad_aki_boxplot$sad <- factor(mimic_sad_aki_boxplot$sad,levels = c("0","1"),labels = c("非谵妄组","谵妄组"))#将分组设置标签
library(tidyverse)
library(ggpubr)
ggboxplot(mimic_sad_aki_boxplot,x="sad",y="hospstay_90d",color = "sad",
          #palette = c("orange","green"),
          ggtheme = theme_bw(),
          legend.title="组别",
          legend.labs=c("非谵妄组","谵妄组"),
          xlab = "",
          ylab = "住院时间（天）",
          ylim = c(0,100)
          #main= "MIMIC-IV 数据库中谵妄组和非谵妄组的 ICU 住院时间箱线图"
          )+
  #stat_compare_means()#添加Wilcoxon秩和检验计算的P值+
  #stat_compare_means(label = "p.signif",
                     #symnum.args = list(cutpoints=c(0,0.0001,0.001,0.01,0.05,Inf),
                                        #symbols=c("<0.0001","<0.001","<0.01","<0.05","ns")))
stat_compare_means(label = "p.signif",
                   symnum.args = list(cutpoints=c(0,0.01,0.05,Inf),
                                      symbols=c("P<0.01","P<0.05","ns")),#获取区间并设置区间的P值怎么显示
                   label.x.npc = "right",#确定P值的x轴位置
                   label.y.npc = "top")#确定P值的y轴位置